<template>
  <div class="center">
    <van-loading size="50px"  color="#1989fa" vertical>正在登录中...</van-loading>
  </div>
</template>

<script setup>
import {onMounted, ref} from "vue";
import {showFailToast, showSuccessToast} from "vant";
import myAxios from "../plugins/myAxios.ts";



onMounted(async () => {
    const urlParams = new URLSearchParams(window.location.search);
    const code = urlParams.get('code');
  if (code) {
    const res = await myAxios.post("/login/loginInfo", {
      code: code
    })
    if(res.code === 0&&res.data!=null){
      showSuccessToast("登录成功");
      //跳转到之前的页面
      const redirectUrl = '/';

      window.location.href = redirectUrl;
      window.location.replace("/");


    }else{
      showFailToast("登录失败" + `,${res.data.description}`);
    }
  }

  })
</script>

<style scoped>
.center {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh; /* 将父容器的高度设置为视窗的高度，使其垂直居中 */
}
</style>